package models

import (
	"bufio"
	"io"

	"github.com/astaxie/beego/orm"
	"os"

	"fmt"
)

func DataReset() (bool,error) {
	f, err := os.Open("datareset.sql")
	if err != nil {
		return false,err
	}
	defer f.Close()
	o := orm.NewOrm()
	buf := bufio.NewReader(f)
	for  {
		line,err := buf.ReadString(';')
		if err != nil {
			if err == io.EOF {
				return true,err
			}
			return false,err
		}

		res ,err  := o.Raw(line).Exec()
		if err != nil {
			return false,err
		}
		fmt.Println(res)
	}

}
